package com.xiaoshuidi.cloud.module.rooms.enums;

import cn.hutool.core.lang.Assert;
import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Arrays;

/**
 * @Description 租赁空间-商铺类型枚举
 * @Param
 * @Return
 * @Date 2023/5/15 15:50
 * @Author Link
 **/
@Getter
@AllArgsConstructor
public enum RentSpaceTypeEnum {
    SHOPS("1","商铺","301"),
    OFFICE("2","办公室","401"),
    OTHERS("0","其他","501"),
    ;

    private String value;
    private String name;
    private String spaceNoLast;

    public static String getValueByName(String name) {
        RentSpaceTypeEnum rentSpaceTypeEnum = Arrays.stream(RentSpaceTypeEnum.values()).filter(p -> p.name.equals(name)).findFirst().orElse(null);
        Assert.isTrue(rentSpaceTypeEnum != null,"RentSpaceTypeEnum类型:{}不存在",name);
        return rentSpaceTypeEnum.getValue();
    }

    public static String getSpaceNoLastByValue(String value) {
        RentSpaceTypeEnum rentSpaceTypeEnum = Arrays.stream(RentSpaceTypeEnum.values()).filter(p -> p.value.equals(value)).findFirst().orElse(null);
        Assert.isTrue(rentSpaceTypeEnum != null,"RentSpaceTypeEnum类型:{}不存在",value);
        return rentSpaceTypeEnum.getSpaceNoLast();
    }

}
